<div class="layui-form hisi-search">
    <form action="{:url()}" method="get" id="hisi-table-search">
        <div class="layui-form-item">
            <label class="layui-form-label">关键词&nbsp;</label>
            <div class="layui-input-inline">
                <input type="text" name="keyword" class="layui-input" lay-verify="required" placeholder="文件名" />
            </div>
        </div>
        <div class="layui-form-item hisi-search-btn">
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-normal layui-icon layui-icon-search">查询</button>
            </div>
        </div>
        

        <!-- <div class="layui-btn-group fl">
            <button type="button" class="layui-btn" id="test3" name="file"><i class="layui-icon"></i>导入excel</button>
        </div> -->
    </form>
</div>


<table class="layui-hide" id="dataTable"></table>
<script type="text/html" id="imgTpl">
    <div style="line-height:18px;">
        <img src="{{ d.pic ? d.pic : '' }}" width="150px" class="fl">
</script>
<script type="text/html" title="操作" id="buttonTpl">
    <a href="{:url('del')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger hisi-tr-del">删除</a>
</script>
{include file="block/layui" /}
<script id="toolbar" type="text/html">
    <a href="{:url('add')}?type=items" class="layui-btn layui-btn-normal layui-btn-sm hisi-iframe-pop" hisi-data="{width: '550px', height: '420px', title: '添加'}">&nbsp;添加</a>
    <a href="javascript:exports();" class="layui-btn layui-btn-primary layui-icon layui-icon-download-circle">&nbsp;导出</a>
</script>
<script type="text/javascript">
    layui.use(['table'], function(){
        var table = layui.table;
        
        table.render({
            elem: '#dataTable'
            ,url:'{:url()}' //数据接口
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter','exports']
            ,cols: [[
            {type:'numbers', title: '序号'}
                ,{field: 'pic', title: '预览',templet: '#imgTpl'}
                ,{field: 'name', title: '文件名'}
                ,{field: 'size', title: '文件大小'}
                ,{field: 'type', title: '图片类型'}
                ,{field: 'ctime', title: '创建时间',templet:"<div>{{layui.util.toDateString(d.ctime*1000, 'yyyy-MM-dd HH:mm:ss')}}</div>"}
                ,{title: '操作', width: 120, templet: '#buttonTpl'}
            ]]
            ,done: function(){
                if (typeof(layui.global.addTableTool) !== 'undefined') {
                    layui.global.addTableTool();
                }
            }
        });

        var laydate = layui.laydate;
  
        //执行一个laydate实例
        laydate.render({
            elem: '.datepicker' //指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '.datepicker1' //指定元素
            ,type: 'datetime'
        });
    });

    function exports(){
        var $ = layui.jquery;
        var bg_time = $(".field-bgTime").val();
        var end_time = $(".field-endTime").val();
        if(!bg_time){
            bg_time = 0;
        }
        if(!end_time){
            end_time = 0;
        }
        window.location.href="{:url('qrcode_export_excel')}?bg_time="+bg_time+"&end_time="+end_time;
    }
</script>